﻿using System.Web.Mvc;
using System.Web.Mvc.Html;
using System;
using System.Linq.Expressions;
namespace ASPItalia.ModelVirtualCasting.Web.Utils
{
    public static class HtmlExtensions
    {
        public static string ImageActionLink(this HtmlHelper helper, string imageUrl, string alternateText, string actionName, string controllerName, object routeValues)
        { 
            var tagBuilder = new TagBuilder("img");
            tagBuilder.MergeAttribute("src", imageUrl);
            tagBuilder.MergeAttribute("alt", alternateText);
            string text = tagBuilder.ToString();

            return helper.ActionLink("**REPLACETHIS**", actionName, controllerName, routeValues, null).ToString().Replace("**REPLACETHIS**", tagBuilder.ToString());
        }

        public static string ImageActionLink(this HtmlHelper helper, string imageUrl, string alternateText, string actionName, object routeValues)
        {
            return ImageActionLink(helper, imageUrl, alternateText, actionName, null, routeValues);
        }
    }
}